package be.rugbyclubleuven.rachel.controller.rest;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import be.rugbyclubleuven.rachel.controller.util.ControllerUtils;
import be.rugbyclubleuven.rachel.domain.Lid;
import be.rugbyclubleuven.rachel.service.RachelService;

/**
 * A controller class that handles all actions concerning club members.
 * 
 */
@Controller
@RequestMapping("/leden")
public class LidController {

	@Autowired
	private RachelService rachelService;

	protected static final Logger LOGGER = LoggerFactory.getLogger(LidController.class);

	/**
	 * Gets the detail of the member with given identifier.
	 * @param id uniquely identifies the member
	 * @return the detail of the member
	 */
	@RequestMapping(value = "/{id}", method = RequestMethod.GET)
	@ResponseBody
	public Map<String, ? extends Object> getById(@PathVariable Long id) {
		Lid lid = rachelService.getLid(id);
		return ControllerUtils.getObjectMap(lid);
	}

	/**
	 * Sets the rachel service. FOR TEST PURPOSE ONLY !
	 * 
	 * @param rachelService The rachel service to be set.
	 */
	public final void setRachelService(RachelService rachelService) {
		this.rachelService = rachelService;
	}

}
